package src.cl.movix.repositories;

public class RepositoryFactory {

	/**
	 * This method is responsible of creating and initialize a postgreSQL
	 * repository.
	 * 
	 * @param access
	 *            The access to the given repository.
	 * 
	 * @return An initialized postgreSQL repository access API for testing.
	 * @throws RepositoryException
	 *             Thrown whenever something goes wrong with the creation of the
	 *             database connection.
	 */
	public static Repository createPostgreSQLRepository(RepositoryAccess access)
			throws RepositoryException {

		/* Return an initialized repository */
		return new SQLRepository(access);
	}

	public static Repository createRepository(RepositoryAccess access)
			throws RepositoryException {
		switch (access.getRepositoryType()) {
		case PostgreSQL:
			return createPostgreSQLRepository(access);
		default:
			break;
		}

		throw new RepositoryException("No existe soporte para ese repositorio");
	}

}
